home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 47 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4dgj4m$9la@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 16 Jan 1996 16:18:30 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 16 Jan 96 18:30:56 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Throwing an exception from within a si
  9. Organization: Sun Microsystems Inc.
  10. References: <4dekiv$22h@galaxy.ucr.edu>
  11. Reply-To: clamage@Eng.Sun.COM
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMPvu7OEDnX0m9pzZAQEi9AF/UstnNv+pm4V+r8uEmGF/BwOEQSZ5pH8s
  14.     XU7QajGQt2NJ7u5PUO/3ykLP9E0nTd7o
  15.     =a18R
  16.  
  17. In article 22h@galaxy.ucr.edu, thp@cs.ucr.edu (Tom Payne) writes:
  18. >
  19. >Implicit in a qestion of what the Standard says are the related
  20. >questions of what it should say and why --- why shouldn't signal
  21. >handlers be allowed to throw exceptions?  (The question seems both
  22. >interesting and appropriate.)
  23.  
  24. Exceptions are synchronous, and unwind the stack from the point of the 
  25. throw to the point of the handler. When an asynchronous signal arrives,
  26. what is the state of the stack? Answer: unknown. In particular, the
  27. stack might not even be in a consistent state -- arguments half pushed
  28. during function entry or half popped during exit.
  29.  
  30. In C, a signal handler isn't allowed to do much of anything, precisely
  31. because the program state can't be known and may be inconsistent. The
  32. same is true in C++.
  33.  
  34. Allowing exceptions to be thrown from a signal handler would place a
  35. noticeable penalty on all programs to provide locks on every function
  36. entry and exit, even programs that didn't throw exceptions or use
  37. signals.
  38. ---
  39. Steve Clamage, stephen.clamage@eng.sun.com
  40. ---
  41. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  42.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  43.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  44.